<template>
	<view>
		<view class="×" @click="huitui">×</view>
		<view class="user">
			<text class="title">重置密码</text>
			<wd-input class="Input" v-model="password" prefix-icon="lock-off" clearable show-password placeholder="请设置新密码" />
			<wd-input class="Input" v-model="again_password" prefix-icon="lock-off" clearable show-password placeholder="请再次输入新密码" />
			<button class="login_Button" @click="reset">重置</button>
			<wd-toast />
		</view>
	</view>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { resetpassword } from '../../api/api';
import { useToast } from '@/uni_modules/wot-design-uni';

const toast = useToast();

const props = defineProps<{ tel: string }>();
let password = ref('');
let again_password = ref('');

const tel = ref('');
tel.value = props.tel;
console.log(tel);

const reset = async () => {
	let data = await resetpassword({ tel: tel.value, password: password.value });
	if (data.code == 200) {
		toast.success({
			iconClass: 'star',
			msg: '重置成功'
		});
		let a = setTimeout(() => {
			uni.redirectTo({
				url: '/pages/Login/Login'
			});
			clearTimeout(a);
		}, 2000);
	} else {
		toast.error({
			iconClass: 'star',
			msg: '新密码不能和老密码一致'
		});
	}
};

const huitui = () => {
	uni.navigateBack({
		delta: 1
	});
};
</script>

<style lang="scss" scoped>
.× {
	width: 60px;
	height: 60px;
	font-size: 60rpx;
	text-align: center;
	line-height: 60px;
}
.user {
	margin: 20px;
	position: relative;
	.title {
		display: block;
		font-size: 40px;
		margin-top: 100px;
		margin-bottom: 60px;
	}
	.Input {
		margin-bottom: 50rpx;
	}
	.forget {
		position: absolute;
		right: 0;
	}
	.login_Button {
		margin-top: 80px;
		background-color: yellow;
		margin-bottom: 20px;
	}
	.enroll {
		position: fixed;
		left: 50%;
		bottom: 10%;
		color: black;
		margin-left: -16px;
	}
	.wechat_login {
		position: fixed;
		left: 50%;
		bottom: 15%;
		margin-left: -5rem;
		width: 10rem;
		background-color: white;
		border: 1px solid gray;
		color: gray;
		border-radius: 50px;
	}
}
</style>
